﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BanXeTang
{
    public abstract class Tank : Character
    {
        public VienDan _dan = new VienDan();
        public int iDoTre;
        public int nDoTre;
        public bool tiepTucBan = true; 
        public float tocDo;
        public int mau;//máu hiện tại
        public int maxMau;//Số lượng máu tối đa

        public virtual void Reset()
        {
            
        }
        public virtual void Ban()
        {
            tiepTucBan = false;
            if (AmThanh.moAmThanh)
                AmThanh.tiengBan.Play();
            _dan = (VienDan)Game1.characterManager.CreateObject(1);

            switch (huong)
            {
                case 0:
                    {
                        _dan.X = X + _sprite[0].texture2d[0].Width / 2 - 3;
                        _dan.Y = Y;
                        break;
                    }
                case 1:
                    {
                        _dan.X = X + _sprite[0].texture2d[0].Width - 3;
                        _dan.Y = Y + 15;
                        break;
                    }
                case 2:
                    {
                        _dan.X = X + _sprite[0].texture2d[0].Width / 2 - 3;
                        _dan.Y = Y + _sprite[0].texture2d[0].Height / 2;
                        break;
                    }
                case 3:
                    {
                        _dan.X = X - _dan._sprite[huong].texture2d[0].Width + 20;
                        _dan.Y = Y + 18;
                        break;
                    }
            }

            _dan.huong = huong;
            _dan.duocBan = true;
            
        }
        public override bool CheckCollisions(MySprite ms)
        {
            for (int i = 0; i < _nsprite; i++)
            {
                if (_sprite[i].CheckCollisions(ms))
                {
                    return true;
                }
            }
            return false;
        }
        public override bool CheckCollisions(VisibleGameEntity t)
        {
            for (int i = 0; i < _nsprite; i++)
            {
                for (int j = 0; j < t._nsprite; j++)
                {
                    if (this._sprite[i].CheckCollisions(t._sprite[j]))
                    {
                        //QuayDau();

                        return true;
                    }
                }
            }
            return false;
        }

        public override void TrungDan(int mauMat)
        {
            mau = mau - mauMat;
        }

        public override int CheckMau()
        {
            return mau;
        }

    }
}
